package com.ctshk.rpc.goods.mapper.provider;

import org.apache.ibatis.jdbc.SQL;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctshk.rpc.goods.dto.ShoppingShopDTO;
import com.ctshk.rpc.goods.req.ShoppingShopPageReq;

/**
 * 商城管理-分页列表查询
 * @author 姜斌文
 * @since 2021-04-06
 */
public class ShoppingShopProvider {

    public String findShoppingShopByAll(IPage<ShoppingShopDTO> page,ShoppingShopPageReq pageReq) {
    	String sql = new SQL() {{
                SELECT("t.id, t.shop_logo, t.shop_default_picture, t.shop_name, t.shop_describe, t.status, t.create_id,operator_id,"
                		+ "(SELECT group_concat(w.words) FROM `ctshk-goods`.t_shopping_shop_key_word w WHERE w.shop_id = t.id) AS \"words\"");
                FROM("`ctshk-goods`.t_shopping_shop t");
                if(pageReq.getUserIds() != null){
                    WHERE("t.create_id in (${pageReq.userIds})");
                }
                ORDER_BY("t.gmt_create DESC");
            }}.toString();
            return sql;
    }
}
